﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;

namespace employee.Controls
{
    public partial class emWorkHistoryDetail : common.controls.baseUserControl
    {
        public emWorkHistoryDetail()
        {
            InitializeComponent();
        }
        protected void SetDataSource(BindingSource dataSrc)
        {
            common.BindingLibs.BindObject(this.startDateEd, dataSrc, DataAccess.DataCache.myBaseDS.emWorkHistory.startDateColumn.ColumnName);
            common.BindingLibs.BindObject(this.endDateEd, dataSrc, DataAccess.DataCache.myBaseDS.emWorkHistory.enDateColumn.ColumnName);

            common.BindingLibs.BindObject(this.workPossitionCb, dataSrc, DataAccess.DataCache.myBaseDS.emWorkHistory.workPossitionColumn.ColumnName);
            common.BindingLibs.BindObject(this.workDescEd, dataSrc, DataAccess.DataCache.myBaseDS.emWorkHistory.workDescColumn.ColumnName);
            common.BindingLibs.BindObject(this.companyNameEd, dataSrc, DataAccess.DataCache.myBaseDS.emWorkHistory.companyNameColumn.ColumnName);
            common.BindingLibs.BindObject(this.comContactNameEd, dataSrc, DataAccess.DataCache.myBaseDS.emWorkHistory.comContactNameColumn.ColumnName);
            common.BindingLibs.BindObject(this.comContactEmailEd, dataSrc, DataAccess.DataCache.myBaseDS.emWorkHistory.comContactEmailColumn.ColumnName);
            common.BindingLibs.BindObject(this.comContactPhoneEd, dataSrc, DataAccess.DataCache.myBaseDS.emWorkHistory.comContactPhoneColumn.ColumnName);
            common.BindingLibs.BindObject(this.comContactPossiotonCb, dataSrc, DataAccess.DataCache.myBaseDS.emWorkHistory.comContactPositionColumn.ColumnName);

            this.companyNameEd.MaxLength = DataAccess.DataCache.myBaseDS.emWorkHistory.companyNameColumn.MaxLength;
            this.companyAddEd.MaxLength = DataAccess.DataCache.myBaseDS.emWorkHistory.companyAddrColumn.MaxLength;
            this.comContactNameEd.MaxLength = DataAccess.DataCache.myBaseDS.emWorkHistory.comContactNameColumn.MaxLength;
            this.comContactEmailEd.MaxLength = DataAccess.DataCache.myBaseDS.emWorkHistory.comContactEmailColumn.MaxLength;
            this.comContactPhoneEd.MaxLength = DataAccess.DataCache.myBaseDS.emWorkHistory.comContactPhoneColumn.MaxLength;
            this.workDescEd.MaxLength = DataAccess.DataCache.myBaseDS.emWorkHistory.workDescColumn.MaxLength;
        }

        public virtual void Init(BindingSource dataSrc) 
        {
            workPossitionCb.LoadData();
            comContactPossiotonCb.LoadData();
            SetDataSource(dataSrc);
        }

        public virtual bool CheckData()
        {
            bool retVal = true;
            ClearNotifyError();

            //if (startDateEd.myValue == common.Consts.constNullDate)
            //{
            //    NotifyError(startDateLbl);
            //    retVal = false;
            //}
            //if (endDateEd.myValue == common.Consts.constNullDate)
            //{
            //    NotifyError(endDateLbl);
            //    retVal = false;
            //}
            //if (companyNameEd.Text.Trim() == "")
            //{
            //    NotifyError(companyNameLbl);
            //    retVal = false;
            //}
            //if (companyAddEd.Text.Trim() == "")
            //{
            //    NotifyError(companyAddLbl);
            //    retVal = false;
            //}
            //if (workPossitionCb.myValue == "")
            //{
            //    NotifyError(workPossitionLbl);
            //    retVal = false;
            //}
            return retVal;
        }
        public virtual void LockEdit(bool state)
        {
            state = !state;
            startDateEd.Enabled = state;
            endDateEd.Enabled = state;
            workPossitionCb.Enabled = state;
            employerPnl.Enabled = state;
            workDescEd.Enabled = state;
        }
        public virtual void SetFocus()
        {
            this.Focus();
            startDateEd.Focus();
        }
    }
}
